<!-- <template>
	<view class="reply-container">
		<view v-if="checkList.length" class="check-content" style="margin-bottom: 20rpx;">
			<view class="check-title">巡逻检查项{{'(' + checkList.length + ')'}}</view>
			<view  class="check-item" v-for="(item, index) in checkList" :key="item['检查项id']">
				<view :class="{'rightColor': item['合格'] == 1, 'wrongColor': item['合格'] === 0}">
					{{index+1}}、{{item['检查项名字']}}
				</view>
				<view class="check-result">
					<uni-data-checkbox  :selectedColor="item['合格'] == 1 ? '#33cc33' : 'red'"  v-model="item['合格']" :localdata="status"></uni-data-checkbox>
				</view>
			</view>
		</view>
		<view style="padding: 20rpx;">
			<view class="title"><text style="color: red;">*</text>完成描述</view>
			<textarea style="height: 320rpx;" :maxlength="500" class="content" v-model="params['完成描述']"
				placeholder="请输入巡逻描述..." name="" id="" cols="30" rows="10"></textarea>
		</view>
		<view class="title" style="margin-left: 20rpx;"><text style="color: red;">*</text>完成附件</view>
		<view style="margin-left: 8rpx;">
			<uploader :max="10" @input='onchange'></uploader>
		</view>
		<button style="margin-bottom: 60rpx;" class="patrol-btn" @click="submit">提交</button>
	</view>
</template>

<script>
	import uploader from '@/components/my-components/image-uploader.vue'
	export default {
		data() {
			return {
				taskId: null,
				status: [{
						text: '合格',
						value: 1
					},
					{
						text: '不合格',
						value: 0
					}
				],
				checkList: [],
				params: {
					id: null,
					完成描述: '',
					附件: [],
					是否超出距离: null,
					超出距离原因: null,
					定位距离: null,
					定位经度: null,
					定位维度: null,
					位置: ''
				}
			}
		},
		components: {
			uploader
		},
		onLoad(options) {
			// console.log('数据', JSON.parse(options.item))
			if (options.item) {
				this.params = Object.assign({}, this.params, JSON.parse(options.item))
				this.taskId = +JSON.parse(options.item).任务id
				let checkRecord = JSON.parse(options.item).检查项记录 || []
				for (let i = 0; i < checkRecord.length; i++) {
					this.checkList.push({
						任务记录id: checkRecord[i].任务记录id,
						检查项id: checkRecord[i].检查项id,
						检查项名字: checkRecord[i].检查项名字,
						合格: ''
					})
				}
			}
			if (options.id) {
				this.params.id = +options.id
				this.taskId = +options.taskId
			}

		},
		methods: {
			onchange(e) {
				this.params.附件 = e
			},
			submit() {
				let flag = this.checkList.find(item => item.合格 === '')
				console.log(this.params)
				if(this.checkList.length && flag) {
					uni.showToast({
						title: '当前还有未勾选的巡逻项',
						icon: 'none'
					})
				}else if (this.params.完成描述.trim() == '') {
					uni.showToast({
						title: '请填写完成描述',
						icon: 'none'
					})
				} else if (!this.params.附件.length) {
					uni.showToast({
						title: '请上传巡逻附件',
						icon: 'none'
					})
				} else {
					uni.showLoading({
						mask: true
					})
					if(this.checkList.length) {
						this.completePatrol()
						return
					}
					this.completeCommon()
				}
			},
			async completePatrol() {
				const res = await this.$http.post('taskSystem/task/itemRecord/submit', {
					检查项: this.checkList
				})
				const res1 = await this.$http.post('taskSystem/task/patrolPoint/submit', this.params)
				if (res.code === 10000 && res1.code === 10000) {
					uni.redirectTo({
						url: '/taskSystem/operateSuccess/operateSuccess?path=../patrolTaskDetail/patrolTaskDetail' + '&id=' + this.taskId
					})
				}
			},
			completeCommon() {
				this.$http.post('taskSystem/task/patrolPoint/submit', this.params).then(res => {
					// console.log(res)
					if (res.code === 10000) {
						uni.redirectTo({
							url: '/taskSystem/operateSuccess/operateSuccess?path=../facilityCheckDetail/facilityCheckDetail' + '&id=' + this.taskId
						})
					}else if(res.code === 50001) {
						uni.showToast({
							title: '提交失败,任务还未开始',
							icon: 'none'
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.rightColor {
		color: #33cc33;
		// color: #49B980;
	}
	.wrongColor {
		color: red;
	}
	.check-content {
		height: auto;
		background-color: #fff;
		padding: 20rpx;

		.install-type {
			font-size: 36rpx;
		}

		.check-title {
			height: 80rpx;
			font-size: 40rpx;
			text-align: center;
			line-height: 60rpx;
			border-bottom: 2rpx solid #DEDEDE;
			margin-bottom: 30rpx;
		}

		.check-item {
			margin-bottom: 40rpx;
			font-size: 32rpx;

			.unquality-check-item {
				width: 674rpx;
				height: 258rpx;
				padding: 20rpx;
				border: 2rpx solid #B5B5B5;
				margin-bottom: 20rpx;

				.desc {
					margin-bottom: 20rpx;
					display: flex;

					input {
						width: 450rpx;
					}
				}

				.img-content {
					display: flex;

					.img-item {
						width: 140rpx;
						height: 140rpx;
						margin: 10rpx;

						.img {
							width: 100%;
							height: 100%;
						}
					}
				}
			}
		}

		.check-result {
			display: flex;
			align-items: center;
			justify-content: flex-end;

			.switch {
				color: #3080FB;
			}
		}
	}

	.reply-container {
		padding-bottom: 60rpx;
		// padding: 20rpx;
		.title {
			margin-bottom: 20rpx;
		}

		.content {
			width: 710rpx;
			padding: 20rpx;
			border: 2rpx solid #ccc;
		}

		.patrol-btn {
			width: 568rpx;
			height: 80rpx;
			line-height: 80rpx;
			margin-top: 200rpx;
			background: linear-gradient(to right, #3350D9, #1152FC);
			// background-color: #1152FC;
			color: #fff;
		}

		.sign-item {
			margin-left: 20rpx;
			width: 220rpx;
			height: 220rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}
	}
</style>
 -->
 
 
 <template>
 	<view class="reply-container">
 		<view style="padding: 20rpx;">
 			<view class="title"><text style="color: red;">*</text>完成描述</view>
 			<textarea style="height: 320rpx;"  :maxlength="500" class="content" v-model="params['完成描述']" placeholder="请输入巡逻描述..." name="" id="" cols="30" rows="10"></textarea>
 		</view>
 		<view class="title" style="margin-left: 20rpx;"><text style="color: red;">*</text>完成附件</view>
 		<view style="margin-left: 8rpx;">
 			<uploader :max="10" @input='onchange'></uploader>
 		</view>
 		<button class="patrol-btn" @click="submit">提交</button>
 	</view>
 </template>
 
 <script>
 	import uploader from '@/components/my-components/image-uploader.vue'
 	export default {
 		data() {
 			return {
				taskId: null,
 				params: {
 					id: null,
 					完成描述: '',
 					附件	: [],
 					是否超出距离: null,
 					超出距离原因: null,
 					定位距离: null,
 					定位经度: null,
 					定位维度: null,
 					位置: ''
 				}
 			}
 		},
 		components: {
 			uploader
 		},
 		onLoad(options) {
 			if(options.item) {
 				this.params = Object.assign({}, this.params, JSON.parse(options.item))
				// console.log('id11', +JSON.parse(options.item).任务id)
				this.taskId = +JSON.parse(options.item).任务id
 			}
 			if(options.id) {
 				this.params.id = +options.id
				this.taskId = +options.taskId
 			}
 			
 		},
 		methods: {
 			onchange(e) {
 				this.params.附件 = e
 			},
 			submit() {
 				console.log(this.params)
 				if(this.params.完成描述.trim() == ''){
 					uni.showToast({
 						title: '请填写完成描述',
 						icon: 'none'
 					})
 				}else if(!this.params.附件.length){
 					uni.showToast({
 						title: '请上传巡逻附件',
 						icon: 'none'
 					})
 				}else {
 					uni.showLoading({mask: true})
 					this.completePatrol()
 				}
 			},
 			completePatrol() {
 				// this.params.id = parseInt(this.ticketId)
 				// this.params.操作类型 = 'complete'
 				uni.showLoading({mask: true})
 				this.$http.post('taskSystem/task/patrolPoint/submit', this.params).then(res => {
 					console.log(res)
 					if (res.code === 10000) {
 						// uni.redirectTo({
 						// 	url: '/ticketSystem/acceptSuccess/acceptSuccess?path=/taskSystem/index/index' + '&title=返回任务首页'
 						// })
 						uni.redirectTo({
 							url: '/taskSystem/operateSuccess/operateSuccess?path=../facilityCheckDetail/facilityCheckDetail' + '&id=' + this.taskId
 						})
 					}else {
						uni.showToast({
							title: '提交失败,请稍后重试',
							icon: 'none'
						})
					}
 				})
 			}
 		}
 	}
 </script>
 
 <style lang="scss">
 	.reply-container {
 		// padding: 20rpx;
 		.title {
 			margin-bottom: 20rpx;
 		}
 		.content {
 			width: 710rpx;
 			padding: 20rpx;
 			border: 2rpx solid #ccc;
 		}
 		.patrol-btn {
 			width: 568rpx;
 			height: 80rpx;
 			line-height: 80rpx;
 			margin-top: 200rpx;
 			background: linear-gradient(to right, #3350D9, #1152FC);
 			// background-color: #1152FC;
 			color: #fff;
 		}
 		.sign-item {
 			margin-left: 20rpx;
 			width: 220rpx;
 			height: 220rpx;
 			image {
 				width: 100%;
 				height: 100%;
 			}
 		}
 	}
 </style>